<script type="text/javascript">
	function doSearchRoom(value) {
		
	}
	
	//表格查询  
	function reloadRoom() {
		var params = room_list.datagrid('options').queryParams; //先取得 datagrid 的查询参数  
		printLog(params);
		room_list.datagrid('reload'); //设置好查询参数 reload 一下就可以了  
		room_list.datagrid('unselectAll');
		room_list.datagrid('uncheckAll');
	}


	function addRoom() {
		createFromWindowOptions({
			title:"新增信息",
			maximizable:true,
			href: "room.do?editRoom",
			callback:function(data) {
				saveRoomInfo();
			},
			enableSaveButton:true
		});
	}
	
	function deleteRoom() {
		var rows = room_list.datagrid('getChecked');
	    if (rows&&rows.length>0){
	        $.messager.confirm('询问','你确认要删除吗?',function(r){
	            if (r){
	            	var ids = "";
	            	for(var i=0; i<rows.length; i++){
	            		ids += rows[i].id+",";
	            	}
	                $.post('room.do?deleteRoomItems',{ids:ids},function(result){
	                    if (result.success){
	                    	reloadRoom();    
	                    }
	                    showMsg(result.msg);
	                },'json');
	            }
	        });
	    }else {
	    	showMsg("请选择操作记录.");
	    }
	}

	function editRoom() {
		var rows = room_list.datagrid('getChecked');
		printLog(rows);
		if (rows&&rows.length>0) {
			if(rows.length>1) {
				showMsg('请选择一条操作记录.');
				return;
			}
			createFromWindowOptions({
				title:"编辑信息",
				maximizable:true,
				href: "room.do?editRoom&roomId=" + rows[0].id,
				callback:function(data) {
					saveRoomInfo();
				},
				enableSaveButton:true
			});
		} else {
			showMsg('请选择操作记录.');
		}

	}
	
	
	//操作按钮触发
	function operationsLookRoom(id) {
		if (id == undefined) {//点击右键菜单才会触发这个
			var rows = room_list.datagrid('getSelections');
			id = rows[0].id;
		}
		if (id) {
			createFromWindow("查看信息", "room.do?editRoom&roomId=" + id,
					null, null,false);
		} else {
			showMsg('请选择查看记录.');
		}
	}
	
	function operationsEditRoom(id) {
		if (id == undefined) {//点击右键菜单才会触发这个
			var rows = room_list.datagrid('getSelections');
			id = rows[0].id;
		}
		if (id) {
			createFromWindowOptions({
				title:"编辑信息",
				maximizable:true,
				href: "room.do?editRoom&roomId=" + id,
				callback:function(data) {
					saveRoomInfo();
				},
				enableSaveButton:true
			});
		} else {
			showMsg('请选择编辑记录.');
		}
	}
	
	function operationsSendRoom() {
		printLog('发送');
	}
	
	function operationsDeleteRoom(id) {
		if (id == undefined) {//点击右键菜单才会触发这个
			var rows = new_list.datagrid('getSelections');
			id = rows[0].id;
		}
		if (id) {
			$.messager.confirm('询问', '你确认要删除吗?', function(r) {
				if (r) {
					$.post('room.do?deleteRoomItems', {
						ids : id
					}, function(result) {
						if (result.success) {
							reloadRoom(); 
						}
						showMsg(result.msg);
					}, 'json');
				}
			});
		} else {
			showMsg("请选择操作记录.");
		}
	}
	
	function downLoadTemplate() {
		downLoadFile('room.do?downLoadRoomTemplate');
	}
	
	function importTemplate() {
// 		createFromWindowOptions({
// 			title:"导入客房模版信息",
// 			maximizable:true,
// 			href: "room.do?skipToTempImport",
// 			callback:function(data) {
// 				submitRoomTemplate();
// 			},
// 			enableSaveButton:true
// 		});
		createFromWindowOptions({
			title:"导入客房模版信息",
			maximizable:false,
			width:400,
			height:200,
			href:'room.do?skipToTempImport',
			callback:function(d) {
				var f  = d.find('#roomImportForm');
				var validate = f.form("validate");
				if (validate) {
					f.submit();
	            } else {
	                return false;
	            }
			},
			enableSaveButton:true
		});
	}
	
	function clearRoomSearch() {
		setGridSearchParams('room_list','roomSearchForm',true,reloadRoom);
	}
	
	//根据条件查询设备
	function roomSearch() {
		setGridSearchParams('room_list','roomSearchForm',false,reloadRoom);
	}
	
	function liveRoom() {
		var rows = room_list.datagrid('getChecked');
		if (rows&&rows.length>0) {
			if(rows.length>1) {
				showMsg('请选择一条操作记录.');
				return;
			}
			fiterRoomStatu(rows[0]);
		} else {
			showMsg('请选择操作记录.');
		}
	}
	
	function leaveRoom() {
		var rows = room_list.datagrid('getChecked');
		if (rows&&rows.length>0) {
			if(rows.length>1) {
				showMsg('请选择一条操作记录.');
				return;
			}
			fiterRoomStatu(rows[0]);
		} else {
			showMsg('请选择操作记录.');
		}
	}
	
	function orderRoom() {
		
	}
	
	function cancleOrderRoom() {
		
	}
</script>

<#assign operations = "[\{shiro:'hotel:room:refresh',onClick:'operationsLookRoom',src:'static/jmax/images/notes/note.png',title:'查看'},
	   					\{shiro:'hotel:room:edit',onClick:'operationsEditRoom',src:'static/jmax/images/notes/note_edit.png',title:'编辑'},
	   					\{shiro:'hotel:room:delete',onClick:'operationsDeleteRoom',src:'static/jmax/images/notes/note_delete.png',title:'删除'}
	  				   ]"/>

<div class="easyui-layout" data-options="fit:true">
	<div data-options="region:'center',border:false">
		
		<@eu.datagrid id="room_list" toolbar="#roomlist_search" idField="id" operations="${operations!}"
			 url="room.do?loadList" rownumbers="true"
			 item="com.xdtech.hotel.vo.RoomItem"/>
		
		<div id="roomlist_search">
			<div style="margin-bottom:5px;padding-left:5px;margin-top: 5px;">
				<form id="roomSearchForm">
					<table>
						<tr>
							<td>所属区域:</td>
							<td>
								<@eu.comboBox url="common.do?loadComboBox&key=SERVICE_AREA" name="serviceArea"/>
							</td>
							<td>房间类型：</td>
							<td>
								<@eu.comboBox url="common.do?loadComboBoxText&key=ROOM_TYPE" name="type" />
							</td>
							<td>房间状态：</td>
							<td>
								<@eu.comboBox url="common.do?loadComboBox&key=ROOM_STATUS" name="status"/>
							</td>
							<td>房间号：</td>
							<td><input type="text" name="roomNo" style="width: 150px" /></td>
							<td>
								<@eu.linkbutton showName="查询" iconCls="icon-search" onclick="roomSearch()"/>
	 					 		<@eu.linkbutton showName="清空" iconCls="icon-clear" onclick="clearRoomSearch()"/>
 					 		</td>
						</tr>
					</table>
				</form>
				
			</div>
			<div id="room_toolbar" style="height: auto">
				<@eu.linkbutton showName="新增" shiro="hotel:room:add" iconCls="icon-add" onclick="addRoom()"/>
				<@eu.linkbutton showName="删除" shiro="hotel:room:delete" iconCls="icon-remove" onclick="deleteRoom()"/>
				<@eu.linkbutton showName="编辑" shiro="hotel:room:edit" iconCls="icon-edit" onclick="editRoom()"/>
				<@eu.linkbutton showName="刷新" shiro="hotel:room:refresh" iconCls="icon-reload" onclick="reloadRoom()"/>
				<@eu.linkbutton showName="入住登记" shiro="hotel:room:live" iconCls="icon-transmit-edit" onclick="liveRoom()"/>
				<@eu.linkbutton showName="离开登记" shiro="hotel:room:leave" iconCls="icon-transmit-go" onclick="leaveRoom()"/>
<!-- 				<@eu.linkbutton showName="预约" shiro="hotel:room:order" iconCls="icon-transmit-add" onclick="orderRoom()"/> -->
<!-- 				<@eu.linkbutton showName="取消预约" shiro="hotel:room:cancleOrder" iconCls="icon-transmit-blue" onclick="cancleOrderRoom()"/> -->
				<@eu.linkbutton showName="下载模板" shiro="hotel:room:downLoadTemplate" iconCls="icon-download" onclick="downLoadTemplate()"/>
				<@eu.linkbutton showName="导入" shiro="hotel:room:importTemplate" iconCls="icon-import" onclick="importTemplate()"/>
			</div>
		</div>
	</div>
</div>